<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>更改挂号--中软高科-2015</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="Css/bootstrap.css" />
<link rel="stylesheet" type="text/css"
	href="Css/bootstrap-responsive.css" />
<link rel="stylesheet" type="text/css" href="Css/style.css" />
<script type="text/javascript" src="Js/jquery.js"></script>
<script type="text/javascript" src="Js/jquery.sorted.js"></script>
<script type="text/javascript" src="Js/bootstrap.js"></script>
<script type="text/javascript" src="Js/ckform.js"></script>
<script type="text/javascript" src="Js/common.js"></script>
<script type="text/javascript" src="Js/ckeditor/ckeditor.js"></script>


<style type="text/css">
body {
	padding-bottom: 40px;
}

.sidebar-nav {
	padding: 9px 0;
}

@media ( max-width : 980px) {
	/* Enable use of floated navbar text */
	.navbar-text.pull-right {
		float: none;
		padding-left: 5px;
		padding-right: 5px;
	}
}
</style>
<script type="text/javascript">
	$(function() {
		$('#backid').click(function() {
			window.location.href = "index.jsp";
		});
	});
</script>
</head>
<body>
	<form action="editPs" method="post" class="definewidth m20"
		onsubmit="return checkForm()">
		<!--onsubmit用于判断表单是否提交的条件,true提交,false不提交,return ****()为固定写法  -->
		<table class="table table-bordered table-hover definewidth m10">
			<tr>
				<td width="10%" class="tableleft"><font color="red">*</font>原密码</td>
				<td><input id="userPassword" type="text" name="userPassword"
					value="" onblur="checkPassword()" /> <span id="sp"></span></td>
			</tr>
			<!--谁调用this就是指的谁  -->
			<tr>
				<td width="10%" class="tableleft"><font color="red">*</font>新密码</td>
				<td><input id="newPasswordd" type="text" name="newPasswordd"
					value="" onblur="newPassword()" /><span id="sp2"></span></td>
			</tr>

			<tr>
				<td width="10%" class="tableleft"><font color="red">*</font>确认密码</td>
				<td><input id="newPassword1d" type="text" name="newPassword1d"
					value="" onblur="newPassword1()" /><span id="sp3"></span></td>
			</tr>

			<tr>
				<td colspan="2">
					<center>
						<button type="submit" class="btn btn-primary" type="button">确认</button>
					</center>
				</td>
			</tr>
		</table>
	</form>
</body>
<script type="text/javascript">
	function checkPassword() {
		var isok = false;
		if ($("#userPassword").val() != null
				&& $("#userPassword").val().trim() != "") {
			$.ajax({
				//提交方式
				type : "post",
				//跳转的servlet
				url : "checkPassword",
				//传入的参数
				data : "code=" + $("#userPassword").val().trim(),
				async : false,
				//同步请求(在ajax里面不写就是默认为异步),目的是造成一定的阻塞,不让后面的代码在此代码还未执行完成时,就执行(提交或者返回).
				success : function(msg) {
					
					//msg为返回servlet里response的返回值,用于servlet逻辑处理之后的判断
					if (msg == 0) {//<font>本身就是标签,可以用于其他标签中间修饰该标签
						$("#sp").html("<font size='5' color='green'>√</font>");
						isok = true;
					} else {
						$("#sp").html("<font size='5' color='red'>×</font>");
					}
				}
			});
		} else {
			$("#sp").html("<font size='5' color='red'>×</font>");
		}
		return isok;//isok拿来后面用于判断
	}

	function newPassword() {
		var isok = false;
		if ($("#newPasswordd").val() != null
				&& $("#newPasswordd").val().trim() != ""
				&& $("#newPasswordd").val().trim() == $("#newPasswordd").val()) {
			$("#sp2").html("<font size='5' color='green'>√</font>");
			isok = true;

		} else {
			$("#sp2").html("<font size='5' color='red'>×</font>");
		}
		return isok;
	}

	function newPassword1() {
		isok = false;
		if ($("#newPassword1d").val() != null
				&& $("#newPassword1d").val() == $("#newPasswordd").val()) {
			$("#sp3").html("<font size='5' color='green'>√</font>");
			isok = true;
		} else {
			$("#sp3").html("<font size='5' color='red'>×</font>");
		}
		return isok;
	}
	//js方法体上不显示返回值,在方法中体现是否有返回值
	function checkForm() {
		alert(123);
		var a = checkPassword();
		var b = newPassword();
		var c = newPassword1(); 
		if (a && b && c) {
			return true;
		} else {
			return false;
		}
	}
</script>

</html>
